/* 基础样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* CSS变量定义 */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --background: #f0f4f8;
    --text: #333;
    --card: #fff;
    --shadow: rgba(0, 0, 0, 0.1);
    --slider-bg: #f3f4f6;
    --slider-text: #666;
    --toast-bg: rgba(255, 255, 255, 0.98);
    --toast-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    --animation-curve: cubic-bezier(0.34, 1.56, 0.64, 1);
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

/* 主题样式 */
body.dark {
    --primary: #60a5fa;
    --primary-dark: #3b82f6;
    --background: #1f2937;
    --text: #f3f4f6;
    --card: #374151;
    --shadow: rgba(0, 0, 0, 0.3);
    --slider-bg: #4b5563;
    --slider-text: #e5e7eb;
    --toast-bg: rgba(55, 65, 81, 0.98);
}

body.warm {
    --primary: #f97316;
    --primary-dark: #ea580c;
    --background: #fff7ed;
    --text: #431407;
    --card: #fff;
    --shadow: rgba(249, 115, 22, 0.1);
    --slider-bg: #fed7aa;
    --slider-text: #9a3412;
    --toast-bg: rgba(255, 247, 237, 0.98);
}

/* 基础布局 */
html {
    height: 100%;
    overflow: hidden;
}

body {
    height: 100%;
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--background);
    color: var(--text);
    transition: background-color 0.3s var(--animation-curve);
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* 防止页面弹跳 */
.prevent-bounce {
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* 顶部工具栏 */
.top-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    padding: 10px 20px;
    padding-top: calc(10px + var(--safe-area-inset-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    background: var(--background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toolbar-left,
.toolbar-right {
    display: flex;
    gap: 8px;
}

/* 工具栏按钮 */
.toolbar-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 22px;
    background: var(--card);
    color: var(--text);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px var(--shadow);
    transition: all 0.3s var(--animation-curve);
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.toolbar-btn.active {
    background: var(--primary);
    color: white;
}

/* 主容器 */
.container {
    position: fixed;
    top: calc(64px + var(--safe-area-inset-top));
    left: 0;
    right: 0;
    bottom: var(--safe-area-inset-bottom);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 500px;
    margin: 0 auto;
}

/* 标题样式 */
h1 {
    font-size: clamp(24px, 5vw, 28px);
    text-align: center;
    background: linear-gradient(45deg, var(--primary), var(--primary-dark));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    margin-bottom: 10px;
}

h1::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 2px;
}

/* 输入框样式 */
.input-box-textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--slider-bg);
    border-radius: 12px;
    font-size: 16px;
    min-height: 120px;
    resize: none;
    background: var(--card);
    color: var(--text);
    transition: all 0.3s var(--animation-curve);
    -webkit-appearance: none;
    appearance: none;
    -webkit-user-select: text;
    user-select: text;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.input-box-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    transform: translateY(-2px);
}

/* 通知按钮 */
.notify-btn {
    width: 100%;
    padding: 15px;
    background: linear-gradient(45deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s var(--animation-curve);
}

.notify-btn i {
    font-size: 20px;
}

.notify-btn:active {
    transform: scale(0.98);
}

/* 滑块样式 */
.call-slider {
    width: 100%;
    height: 50px;
    background: var(--slider-bg);
    border-radius: 25px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s var(--animation-curve);
    touch-action: none;
}

.call-text {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--slider-text);
    font-size: 16px;
    z-index: 1;
    pointer-events: none;
}

.call-handle {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 46px;
    height: 46px;
    background: linear-gradient(45deg, var(--primary), var(--primary-dark));
    border-radius: 23px;
    z-index: 2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 2px 8px var(--shadow);
    transition: transform 0.3s var(--animation-curve);
}

.call-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, 
        rgba(59, 130, 246, 0.1),
        rgba(59, 130, 246, 0.2));
    transition: width 0.1s linear;
}

/* 历史记录 */
.history-toggle {
    width: 100%;
    padding: 12px;
    background: var(--card);
    border: 2px solid var(--slider-bg);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s var(--animation-curve);
}

.history-toggle:hover {
    border-color: var(--primary);
}

.history-list {
    display: none;
    margin-top: 10px;
}

.history-list.show {
    display: block;
    animation: fadeIn 0.3s var(--animation-curve);
}

.history-item {
    background: var(--card);
    border: 2px solid var(--slider-bg);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
}

.history-message {
    margin-bottom: 8px;
    color: var(--text);
}

.history-time {
    font-size: 12px;
    color: var(--slider-text);
}

/* 密码验证弹窗 */
.password-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.password-modal.show {
    display: flex;
}

.password-content {
    background: var(--card);
    padding: 20px;
    border-radius: 16px;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 8px 32px var(--shadow);
    animation: modalShow 0.3s var(--animation-curve);
}

.password-content h3 {
    margin-bottom: 15px;
    text-align: center;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.password-content input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--slider-bg);
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
    background: var(--background);
    color: var(--text);
}

.password-content input:focus {
    outline: none;
    border-color: var(--primary);
}

.password-buttons {
    display: flex;
    gap: 10px;
}

.password-buttons button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s var(--animation-curve);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.password-buttons button:first-child {
    background: var(--primary);
    color: white;
}

.password-buttons button:last-child {
    background: var(--slider-bg);
    color: var(--text);
}

/* Toast提示 */
.toast-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--toast-bg);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: var(--toast-shadow);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--animation-curve);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.toast-container.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.toast-message {
    color: var(--text);
    font-size: 14px;
    text-align: center;
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalShow {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .top-toolbar {
        height: 54px;
        padding: 7px 15px;
        padding-top: calc(7px + var(--safe-area-inset-top));
    }

    .container {
        top: calc(54px + var(--safe-area-inset-top));
        padding: 15px;
    }

    .toolbar-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .notify-btn {
        padding: 12px;
        font-size: 16px;
    }

    .notify-btn i {
        font-size: 18px;
    }

    .call-handle {
        width: 42px;
        height: 42px;
        font-size: 18px;
    }

    .history-toggle {
        padding: 10px;
        font-size: 14px;
    }

    .history-item {
        padding: 12px;
        margin-bottom: 8px;
    }

    .history-time {
        font-size: 11px;
    }

    .password-content {
        width: 85%;
        padding: 15px;
    }
}